package leetcode.code6174;

import java.util.HashMap;
import java.util.Map;

import leetcode.IDebug;

public class Solution implements IDebug {

	public long taskSchedulerII(int[] tasks, int space) {
		long ans = 0;
		Map<Integer, Long> map = new HashMap<>();
		for (int i = 0; i < tasks.length; i++) {
			ans++;
			int type = tasks[i];
			if (map.containsKey(type)) {
				ans = Math.max(ans, map.get(type) + space + 1);
			}
			map.put(type, ans);
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
